package com.ccc3gc.mysystem.service.impl;

import com.ccc3gc.mysystem.VO.DeliveryOrderVO;
import com.ccc3gc.mysystem.VO.OrderVO;
import com.ccc3gc.mysystem.VO.ReceiveOrderVO;
import com.ccc3gc.mysystem.VO.SearchParamVO;
import com.ccc3gc.mysystem.bean.Order;
import com.ccc3gc.mysystem.mapper.OrderMapper;
import com.ccc3gc.mysystem.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    public OrderMapper orderMapper;
    /**
     * 查询订单列表
     *
     * @return orders
     */
    @Override
    public List<OrderVO> selectOrderList(Order order) {
        List<OrderVO> orders = orderMapper.selectOrder(order);
        return orders;
    }

    /**查询用户端订单列表，以及配送员未接单列表
     * @param searchParamVO
     * @return orders
     */
    @Override
    public List<Order> selectOrderListUser(SearchParamVO searchParamVO) {
        List<Order> orders = orderMapper.selectOrderListUser(searchParamVO);
        return orders;
    }

    /**查询用户端，用户订单待取件列表，以及配送员接单列表，详情
     * @param searchParamVO
     * @return receiveOrderVOS
     */
    @Override
    public List<ReceiveOrderVO> selectReceiveOrder(SearchParamVO searchParamVO) {
        List<ReceiveOrderVO> receiveOrderVOS = orderMapper.selectReceiveOrder(searchParamVO);
        return receiveOrderVOS;
    }

    /**查询用户端配送中订单列表，以及配送员配送列表，详情
     * @param searchParamVO
     * @return deliveryOrderVOS
     */
    @Override
    public List<DeliveryOrderVO> selectDeliveryOrder(SearchParamVO searchParamVO) {
        List<DeliveryOrderVO> deliveryOrderVOS = orderMapper.selectDeliveryOrder(searchParamVO);
        return deliveryOrderVOS;
    }

    /**通过订单Id查询订单详情
     * @param orderId
     * @return orderVO
     */
    @Override
    public OrderVO selectOrderByOrderId(int orderId) {
        OrderVO orderVO = orderMapper.selectOrderByOrderId(orderId);
        return orderVO;
    }

    /**
     * @param order
     * @return
     */
    @Override
    public int instertOrder(Order order) {
        int rows = orderMapper.insertOrder(order);
        return rows;
    }

    /**
     * @param order
     * @return
     */
    @Override
    public int updateOrder(Order order) {
        int rows =orderMapper.updateOrder(order);
        return rows;
    }

    /**
     * @param orderId
     * @return
     */
    @Override
    public int deleteOrderById(int orderId) {
        int rows =orderMapper.deleteOrderById(orderId);
        return rows;
    }

    /**
     * @param orderIds
     * @return
     */
    @Override
    public int deleteOrderByIds(List<Integer> orderIds) {
        int rows =orderMapper.deleteOrderByIds(orderIds);
        return rows;
    }
}
